home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / sc3x04.exe / SETDDSR.C < prev    next >
C/C++ Source or Header  |  1993-05-25  |  4KB  |  108 lines

  1. //   IMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;
  2. //   :                                                                    :
  3. //   : module:      setddsr.c                                             :
  4. //   : abstract:    This module shows how to make 3.x system calls using  :
  5. //   :              the F2 Shell Interface for the Set Directory Disk     :
  6. //   :              Space Restriction API, obviously it requires the      :
  7. //   :              NetWare Shell.                                        :
  8. //   :                                                                    :
  9. //   :              This call may need to be made iteratively to return   :
  10. //   :              all of the restriction information.  For simplicity,  :
  11. //   :              this example only makes the call once.                :
  12. //   :                                                                    :
  13. //   : environment: NetWare 3.x v3.11                                     :
  14. //   :              Borland C 3.1                                         :
  15. //   :                                                                    :
  16. //   :  This software is provided as is and carries no warranty           :
  17. //   :  whatsoever.  Novell disclaims and excludes any and all implied    :
  18. //   :  warranties of merchantability, title and fitness for a particular :
  19. //   :  purpose.  Novell does not warrant that the software will satisfy  :
  20. //   :  your requirements or that the software is without defect or error :
  21. //   :  or that operation of the software will be uninterrupted.  You are :
  22. //   :  using the software at your risk.  The software is not a product   :
  23. //   :  of Novell, Inc. or any of subsidiaries.                           :
  24. //   HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM<
  25. //
  26. //     This software is considered pre-release and may be used at your own
  27. //     risk and has been provided due to the many requests of our cust-
  28. //     omers.  Support for this module will be provided at the sole
  29. //     discretion of Novell, Inc.
  30. //
  31.  
  32. #include <stdio.h>
  33. #include <string.h>
  34. #include <stdlib.h>
  35. #include <conio.h>
  36. #include <dos.h>
  37. #include <fcntl.h>
  38. #include <sys\types.h>
  39. #include <sys\stat.h>
  40.  
  41. #include "nwsys.c"
  42.  
  43. //
  44. //  First of all, we define the request structure which is needed for the
  45. //  Set Directory Disk Space Restriction API call.  This structure is
  46. //  laid out according to the System Call documentation.
  47. //
  48.  
  49. struct  REQUEST {
  50.     WORD    sflen;                 // length of the structure
  51.     BYTE    sfcode;                // the subfunction code
  52.     BYTE    dirHandle;             // Directory Handle
  53.     DWORD   diskSpaceLimit;
  54. }Request;
  55.  
  56. // No reply packet required.
  57.  
  58. BYTE GetDirectoryHandle(int diskNumber)
  59. {
  60.     union REGS regs;
  61.  
  62.     memset(®s, 0, sizeof(regs));
  63.  
  64.     regs.h.ah = 0xe9;
  65.     regs.h.al = 0x00;
  66.     regs.x.dx = diskNumber;
  67.  
  68.     intdos(®s,®s);       // do the Int 21
  69.  
  70.     return(regs.h.al);         // return code is in AL
  71. }
  72.  
  73. int main()
  74. {
  75.     int retCode;
  76.     int driveNum;
  77.     char driveLetter[80];
  78.  
  79. //
  80. //  Build the request buffer
  81. //
  82.     Request.sflen = (sizeof Request) ;
  83.     Request.sfcode = 0x24;                  // subfunction code
  84.  
  85.     printf("Enter drive letter: ");
  86.     scanf("%s", driveLetter);
  87.     if (driveLetter[0] <= 'Z')
  88.         driveNum = driveLetter[0] - 'A';
  89.     else
  90.         driveNum = driveLetter[0] - 'a';
  91.     Request.dirHandle = GetDirectoryHandle(driveNum);
  92.  
  93.     printf("Enter disk space restriction: ");
  94.     scanf("%ld", &(Request.diskSpaceLimit));
  95.  
  96.     retCode = NWSystemCall(0x16, &Request, sizeof(Request),
  97.                                  NULL,     0);
  98.  
  99.     if (retCode != 0) {
  100.         printf("Set Directory Disk Space Restriction call failed.  Retcode = %d\n",
  101.             retCode);
  102.         return(-1);
  103.     }
  104.     else
  105.         printf("Set Directory Disk Space Restriction successful.\n");
  106.     return(0);
  107. }
  108.